package com.learn.word.controller;

import com.learn.word.entity.Word;
import com.learn.word.service.IWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Valley
 * Description
 * Created by Valley on 2023/6/19 20:48
 */
@RestController
@RequestMapping("word")
@CrossOrigin
public class WordController {

    @Autowired
    IWord wordService;

    @PostMapping("submit")
    public String submit(@RequestBody Word word){
        wordService.save(word);
        return "success";
    }

    @GetMapping("list")
    public List<Word> wordList(){
        return wordService.list();
    }

}